﻿#region Using region
using System;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
using System.Collections.Specialized;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;


using JigLibX.Physics;
using JigLibX.Collision;
using JigLibX.Geometry;
using JigLibX.Math;
using JigLibX.Utils;
using sqengine.PhysicObjects;
using JigLibX.Vehicles;
using System.Diagnostics;



using sqengine.Engine;
using sqengine.Components;
using sqengine.Engine.Common;


using SqEngine.Components;
using SqEngine.Audio;
using SqEngine;


using PK3Model;
#endregion

namespace sqengine
{

    partial class sqengine : Microsoft.Xna.Framework.Game
    {

        public void ConfigLoad(string filename)
        {
            if (filename == "")
                filename = Content.RootDirectory + "\\Config\\sqengine.cfg";

            if (!(System.IO.Directory.Exists(filename)))
                System.IO.Directory.CreateDirectory(Content.RootDirectory + "\\Config");

            if (System.IO.File.Exists(filename))
            {
                sqconfig = SaveMan.LoadConfig(filename);

                ConsoleSetVar(VAR_SQCONSOLE_ENABLE, sqconfig.ConsoleEnabled.ToString());
                ConsoleSetVar(VAR_SQRES_WIDTH, sqconfig.ResolutionWidth.ToString());
                ConsoleSetVar(VAR_SQRES_HEIGHT, sqconfig.ResolutionHeight.ToString());
                ConsoleSetVar(VAR_SQTRACELOG, sqconfig.Tracelog.ToString());
                ConsoleSetVar(VAR_SQPLAYER_NAME, sqconfig.PlayerName);
                ConsoleSetVar(VAR_SQPLAYER_LOCATION, sqconfig.PlayerLocation);
            }
            else
            {
                this.Window.Title = SqEngine.SqEngineInfo._name + " " + SqEngine.SqEngineInfo._version;

                sqconfig.ResolutionHeight = 600;
                sqconfig.ResolutionWidth = 800;
                sqconfig.Fullscreen = false;
                sqconfig.DebugMode = true;
                sqconfig.ConsoleEnabled = true;
                sqconfig.PlayerName = "Squid";
                sqconfig.PlayerLocation = "Universe";
                sqconfig.IntroEnabled = true;
                sqconfig.IntroFile = "default.intro";
                sqconfig.AntialiasingEnabled = false;
                sqconfig.AntialiasingType = MultiSampleType.TwoSamples;
                sqconfig.BloomEnabled = true;
                sqconfig.Tracelog = false;

                SaveMan.SaveConfig(Content.RootDirectory + "\\Config\\sqengine.cfg", sqconfig);
            }

            TraceLogEnable(isTraceLogEnabled);

        }
    }
}
